/**
*      author: Y_Yao
*      created: 2024-12-08 12:12:33
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 2000 + 7;
int dp[N][N];
string s1,s2;

void solve()
{
    cin >> s1;
    cin >> s2;
    int n = s1.size(),m = s2.size();
    s1 = " " + s1;
    s2 = " " + s2;
    for(int i = 0;i <= m;i++) dp[0][i] = i;
    for(int i = 0;i <= n;i++) dp[i][0] = i;
    for(int i = 1;i <= n;i++)
    {
        for(int j = 1;j <= m;j++)
        {
            if(s1[i] == s2[j])
            {
                dp[i][j] = dp[i-1][j-1];
            }
            else
            {
                dp[i][j] = min(min(dp[i - 1][j - 1] + 1,dp[i - 1][j] + 1),dp[i][j - 1] + 1);
            }
        }
    }
    cout << dp[n][m] << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}